﻿#region Header

/*
Remote views based on linq
By

Pascal Hauser 
Dipl. Ing. in Informatik, Hochschule für Technik Rapperswil, 2006
Master Thesis, Hochschule für Technik Rapperswil, 2008-2010

and

Raphael Gfeller
Dipl. Ing. in Informatik, Hochschule für Technik Rapperswil, 2006
Master Thesis, Hochschule für Technik Rapperswil, 2008-2010

*/

#endregion

#region Usings

using System.Linq;
using System.Windows;
using System.Windows.Markup;
using System.Xml;
using Sebarf.Core.Interfaces;

#endregion

namespace Sebarf.Configuration {
	/// <summary>
	/// Description of the class
	/// </summary>
	public class RequestHandlerLoader {
		#region Public Methods

		/// <summary>
		/// loads the configuration out of a xaml file that contains a <see cref="ResourceDictionary"/>
		/// </summary>
		/// <param name="xamlFile"></param>
		/// <param name="key"></param>
		/// <returns></returns>
		public static IRequestHandler[] Load(string xamlFile) {
			var dictionary = XamlReader.Load(XmlReader.Create(xamlFile)) as ResourceDictionary;
			foreach (object entry in dictionary.Values) {
				if (entry is RequestHandlerCollection) {
					return (entry as RequestHandlerCollection).Handlers.ToArray();
				}
			}
			return new IRequestHandler[] { };
		}

		#endregion

		#region Private Methods

		// private methods located here

		#endregion

		#region Private Fields

		// private fields located here

		#endregion
	}
}